package com.ruoyi.safe.controller.web;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.safe.domain.CommonProject;
import com.ruoyi.safe.domain.dto.ProjectSearchDTO;
import com.ruoyi.safe.domain.dto.StatisticsDto;
import com.ruoyi.safe.domain.vo.CommonProjectVO;
import com.ruoyi.safe.domain.vo.ProjectOverviewVo;
import com.ruoyi.safe.service.ICommonProjectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * PC-首页-统计分析
 *
 * @Auther: lihongming
 * @Date: 2024-01-11 13:33
 * @Description: com.ruoyi.safe.controller.web
 * @Version: 1.0
 */
@RestController
@RequestMapping("/statistics")
public class StatisticsController extends BaseController {

    @Autowired
    private ICommonProjectService commonProjectService;

    /**
     * 项目概况
     * @return
     */
    @GetMapping("/projectOverview")
    public AjaxResult projectOverview(){
        ProjectSearchDTO projectSearchDTO = new ProjectSearchDTO();
        List<CommonProjectVO> commonProjectVOS = commonProjectService.selectCommonProjectList(projectSearchDTO);
        ProjectOverviewVo projectOverviewVo = new ProjectOverviewVo();
        projectOverviewVo.setProjectApproval(commonProjectVOS.stream().filter(p->"1".equals(p.getProjectStatus())).count());
        projectOverviewVo.setConstructing(commonProjectVOS.stream().filter(p->"2".equals(p.getProjectStatus())).count());
        projectOverviewVo.setStop(commonProjectVOS.stream().filter(p->"3".equals(p.getProjectStatus())).count());
        projectOverviewVo.setFinish(commonProjectVOS.stream().filter(p->"4".equals(p.getProjectStatus())).count());
        projectOverviewVo.setCheckAndAccept(commonProjectVOS.stream().filter(p->"5".equals(p.getProjectStatus())).count());
        projectOverviewVo.setYijunweijie(commonProjectVOS.stream().filter(p->"6".equals(p.getProjectStatus())).count());
        projectOverviewVo.setWeikaigong(commonProjectVOS.stream().filter(p->"7".equals(p.getProjectStatus())).count());
        projectOverviewVo.setYiwanweijun(commonProjectVOS.stream().filter(p->"8".equals(p.getProjectStatus())).count());
        projectOverviewVo.setYijunyijie(commonProjectVOS.stream().filter(p->"9".equals(p.getProjectStatus())).count());
        return success(projectOverviewVo);
    }

    /**
     * 隐患治理情况
     *
     * @return
     */
    @GetMapping("/hiddenGovernSituation")
    public AjaxResult hiddenGovernSituation() {

        return success();
    }
}
